<?php

class UsersController extends AppController {

	var $name = 'Users';

	public function beforeFilter(){
		parent::beforeFilter();

	}
	
	public function beforeRender(){
		parent::beforeRender();
	}
	
	function login(){
	    if ($this->request->is('post')) {
	        if ($this->Auth->login()) {
	            return $this->redirect($this->Auth->redirect());
	        } else {
	           SessionComponent::setFlash(__('Username or password is incorrect'), 'default', array(), 'auth');
	        }
	    }
	}
	
	function logout() {
		CakeSession::delete("User");
		CakeSession::delete("Auth");
		CakeSession::delete('Store');
		CakeSession::delete('Timeline',array());
	
		SessionComponent::setFlash(__('You have been successfully logged out of SnapCuts.', true));
		$this->redirect($this->Auth->logout());
	}

}
